home *** CD-ROM | disk | FTP | other *** search
- #include <SetUpA4.h>
- #include <ShutDown.h>
- #include <Timer.h>
-
-
- #include "Makin Copies.h"
- #include "Makin Other.h"
- #include "pStr.h"
-
-
- /* in SwapVolume.c */
- OSErr SwapVolume(short inVRefNum, long inDirID, short *outVRefNum, long *outDirID);
-
-
- void main(void);
-
- pascal void Makin_Copies(WindowPtr copy_Window
- , Str255 window_Name);
-
- void Shutting_Down(void);
- void Restarting(void);
- void Still_Copying(void);
-
-
- TMTask still_Copying_Timer_Task;
- unsigned long setWTitle_Trap_Address;
- long saved_A4;
- Handle handle_To_Ourself;
- Handle snd_MakinCopies;
- Handle snd_Shutdown;
- Handle snd_Throwaway;
- Handle snd_StillMakinCopies;
- Handle snd_Restart;
-
- void main(void)
- {
- short saveVRefNum;
- long saveDirID;
- short deadShort;
- long deadLong;
- SysEnvRec world;
- OSErr err;
- char str[255], str2[255];
- short file_Reference;
- Handle hh;
-
-
- /*************************************************************/
- /***** setup think c for our embedded globals ********/
- /*************************************************************/
- RememberA0();
- SetUpA4();
-
-
- /*************************************************************/
- /***** get the handle to our resource and detach it so we ****/
- /***** will stay around after init time ****/
- /*************************************************************/
- asm
- {
- move.l (sp),saved_A4
- RecoverHandle SYS
- move.l a0,handle_To_Ourself
- }
- DetachResource(handle_To_Ourself);
-
-
-
- /*************************************************************/
- /***** change the finder string to "Makin' Copies:" ********/
- /*************************************************************/
- err = SysEnvirons(1,&world);
- err = SwapVolume(world.sysVRefNum,0,&saveVRefNum,&saveDirID);
-
- file_Reference = OpenResFile((StringPtr)"\pFinder");
- if (ResError() == noErr)
- {
- hh = Get1Resource('STR#',MAKIN_COPY_STR_LIST);
-
- if ( hh != nil )
- {
- if ( *hh == nil )
- LoadResource(hh);
-
- HLock(hh);
-
- pStrCpy((char*)str,"\pItems remaining to be copied:");
- pStrCpy((char*)str2,"\pMakin' Copies:");
-
- Munger(hh, 0L, str, str[0]+1, str2, str2[0]+1);
-
- ChangedResource(hh);
- UpdateResFile(file_Reference);
- CloseResFile(file_Reference);
-
- HUnlock(hh);
- }
- }
-
- err = SwapVolume(saveVRefNum,saveDirID,&deadShort,&deadLong);
-
-
-
- /*******************************************************************/
- /**** load & detach (assume they are not purgable) our sounds ****/
- /*******************************************************************/
- snd_MakinCopies = Get1Resource('snd ',kMakinCopies);
- if ( snd_MakinCopies != 0 )
- {
- if ( *snd_MakinCopies == 0 )
- LoadResource(snd_MakinCopies);
- DetachResource(snd_MakinCopies);
- }
-
- snd_Shutdown = Get1Resource('snd ',kShutdown);
- if ( snd_Shutdown != 0 )
- {
- if ( *snd_Shutdown == 0 )
- LoadResource(snd_Shutdown);
- DetachResource(snd_Shutdown);
- }
-
- /*
- snd_Throwaway = Get1Resource('snd ',kThrowaway);
- if ( snd_Throwaway != 0 )
- {
- if ( *snd_Throwaway == 0 )
- LoadResource(snd_Throwaway);
- DetachResource(snd_Throwaway);
- }
- */
- /*
- snd_StillMakinCopies = Get1Resource('snd ',kStillMakinCopies);
- if ( snd_StillMakinCopies != 0 )
- {
- if ( *snd_StillMakinCopies == 0 )
- LoadResource(snd_StillMakinCopies);
- DetachResource(snd_StillMakinCopies);
- }
- */
-
- snd_Restart = Get1Resource('snd ',kRestart);
- if ( snd_Restart != 0 )
- {
- if ( *snd_Restart == 0 )
- LoadResource(snd_Restart);
- DetachResource(snd_Restart);
- }
-
-
- /*******************************************************************/
- /******** patch SetWTitle() ********/
- /*******************************************************************/
- setWTitle_Trap_Address = GetTrapAddress(SETWTITLE_TRAP);
- SetTrapAddress((long)Makin_Copies, SETWTITLE_TRAP);
-
-
- /*******************************************************************/
- /******** Install the shutdown task to play the sound ********/
- /*******************************************************************/
- ShutDwnInstall((ProcPtr)Shutting_Down, sdOnPowerOff);
-
-
- /*******************************************************************/
- /******** Install the restart task to play the sound ********/
- /*******************************************************************/
- ShutDwnInstall((ProcPtr)Restarting, sdOnRestart);
-
-
- /*******************************************************************/
- /******** Install the timer task for still making copies ********/
- /*******************************************************************/
- /* not working yet
- still_Copying_Timer_Task.tmAddr = (TimerProcPtr)Still_Copying;
- still_Copying_Timer_Task.tmCount = 0;
- still_Copying_Timer_Task.tmWakeUp = 0;
- still_Copying_Timer_Task.tmReserved = 0;
- InsTime((QElemPtr)&still_Copying_Timer_Task);
- */
-
- /*******************************************************************/
- /******** we're out of here ********/
- /*******************************************************************/
- RestoreA4();
- } /* void main(void) */
-
-
-
-
- pascal void Makin_Copies(copy_Window_Ptr,copy_Window_Name)
- WindowPtr copy_Window_Ptr;
- Str255 copy_Window_Name;
- {
- OSErr err;
- short theAddOn;
- Boolean playThe = FALSE;
- long theTime;
-
-
- /*******************************************************************/
- /******** get our globals back ********/
- /*******************************************************************/
- SetUpA4();
-
- /*******************************************************************/
- /********* are they setting the window title to "\pCopy" *********/
- /*******************************************************************/
- if (pStrCmp((char *)copy_Window_Name, COPY_STRING, str_equals, 0L, TRUE) == GOOD) {
- PrimeTime((QElemPtr)&still_Copying_Timer_Task, MS_TIME_BEFORE_STILL_COPYING);
- err = SndPlay(0L, snd_MakinCopies, TRUE);
- }
-
- /*******************************************************************/
- /******** call the original routine ********/
- /*******************************************************************/
- asm
- {
- move.l setWTitle_Trap_Address,a0
- move.l copy_Window_Ptr,-(sp)
- move.l copy_Window_Name,-(sp)
- jsr (a0)
- }
-
- RestoreA4();
- }
-
-
-
- void Shutting_Down(void)
- {
- OSErr err;
-
- SetUpA4();
- err = SndPlay(0L, snd_Shutdown, FALSE);
- RestoreA4();
-
- }
-
-
-
- void Restarting(void)
- {
- OSErr err;
-
-
- SetUpA4();
- err = SndPlay(0L, snd_Restart, FALSE);
- RestoreA4();
-
- }
-
-
-
- /*******************************************************************/
- /******** is the copy window still front most **********/
- /*******************************************************************/
- void Still_Copying(void)
- {
- OSErr err;
- Str255 window_Title;
- WindowPtr front_Window;
-
-
- asm {
- movem.l d0-d7/a0-a6, -(sp)
- }
-
- SetUpA4();
-
-
- /***********
- front_Window = FrontWindow();
-
- GetWTitle(front_Window, window_Title);
-
- if (pStrCmp((char *)window_Title, COPY_STRING, str_equals, 0L, TRUE) == GOOD)
- err = SndPlay(0L, snd_StillMakinCopies, TRUE);
- *****************/
- RestoreA4();
-
- asm {
- movem.l (sp)+, d0-d7/a0-a6
- }
- }
-